package com.weixing.mall.provider.controller.admin;

import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.map.MapUtil;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.weixing.mall.base.orm.MPage;
import com.weixing.mall.base.wrapper.Result;
import com.weixing.mall.base.wrapper.ResultUtil;
import com.weixing.mall.core.annotation.NoNeedAccess;
import com.weixing.mall.core.support.BaseController;
import com.weixing.mall.core.support.auth.AuthUtil;
import com.weixing.mall.core.utils.CommonUtil;
import com.weixing.mall.provider.api.model.enums.OrderTypeEnum;
import com.weixing.mall.provider.model.vo.report.customer.*;
import com.weixing.mall.provider.service.IDayReportCustomerService;
import com.weixing.mall.provider.util.EasyExcelUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.time.DateUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import java.math.BigDecimal;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author jzy
 * @date 2020/5/11
 */
@RestController
@RequestMapping("report")
@Api(value = "后台报表APi", tags = "后台报表-客服部报表")
public class ReportCustomerController extends BaseController {

    @Autowired
    private IDayReportCustomerService reportCustomerService;

    @ApiOperation(value = "1客服部报表--财务日报/正价/代理商活动")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "roleType", value = "角色类型",required = false, paramType = "query"),
            @ApiImplicitParam(name = "agentId", value = "代理商Id",required = false, paramType = "query"),
            @ApiImplicitParam(name = "agentPid", value = "代理商父Id",required = false, paramType = "query"),
            @ApiImplicitParam(name = "pRole", value = "代理商父角色",required = false, paramType = "query"),
            @ApiImplicitParam(name = "startTime", value = "开始时间",required = false, paramType = "query"),
            @ApiImplicitParam(name = "endTime", value = "结束时间",required = false, paramType = "query"),
            @ApiImplicitParam(name = "orderType", value = "订单类型 1正价 2代理活动 3秒杀活动",required = false, paramType = "query"),
            @ApiImplicitParam(name = "actId", value = "活动Id",required = false, paramType = "query"),
            @ApiImplicitParam(name = "actName", value = "活动名称",required = false, paramType = "query"),
            @ApiImplicitParam(name = "sortField", value = "排序字段",required = false, paramType = "query"),
            @ApiImplicitParam(name = "sortType", value = "排序类型  asc正序  desc倒序",required = false, paramType = "query"),
    })
    @GetMapping("/customer/finance")
    public Result<IPage<CustomerReportFinanceVo>> customerFinance(Integer roleType,Long agentId,Long agentPid,Integer pRole,String startTime,String endTime,Integer orderType,Long actId,String actName,String sortField,String sortType){
        IPage<CustomerReportFinanceVo> page = reportCustomerService.customerFinance(roleType,agentId,agentPid,pRole, startTime, endTime, orderType,actId,actName,sortField, sortType,initMpPage());
        return ResultUtil.success(page);
    }
    @ApiOperation(value = "1客服部报表--财务日报/正价/代理商活动-导出excel")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "roleType", value = "角色类型",required = false, paramType = "query"),
            @ApiImplicitParam(name = "agentId", value = "代理商Id",required = false, paramType = "query"),
            @ApiImplicitParam(name = "agentPid", value = "代理商父Id",required = false, paramType = "query"),
            @ApiImplicitParam(name = "pRole", value = "代理商父角色",required = false, paramType = "query"),
            @ApiImplicitParam(name = "startTime", value = "开始时间",required = false, paramType = "query"),
            @ApiImplicitParam(name = "endTime", value = "结束时间",required = false, paramType = "query"),
            @ApiImplicitParam(name = "orderType", value = "订单类型 1正价 2代理活动 3秒杀活动",required = false, paramType = "query"),
            @ApiImplicitParam(name = "actId", value = "活动Id",required = false, paramType = "query"),
            @ApiImplicitParam(name = "actName", value = "活动名称",required = false, paramType = "query"),
            @ApiImplicitParam(name = "sortField", value = "排序字段",required = false, paramType = "query"),
            @ApiImplicitParam(name = "sortType", value = "排序类型  asc正序  desc倒序",required = false, paramType = "query"),
    })
    @GetMapping("/customer/finance/excel")
    @NoNeedAccess
    public void customerFinanceExcel(Integer roleType,Long agentId,Long agentPid,Integer pRole,String startTime,String endTime,Integer orderType,Long actId,String actName,String sortField,String sortType, HttpServletResponse response){
        IPage<CustomerReportFinanceVo> page = reportCustomerService.customerFinance(roleType,agentId,agentPid,pRole, startTime, endTime, orderType,actId,actName,sortField, sortType,new Page(1,-1));
        List<CustomerReportFinanceVo> records = page.getRecords();
        try {
            String fileName="财务日报";
            if (orderType!=null&&orderType==1){
                fileName="正价财务日报";
            }
            if (orderType!=null&&orderType==2){
                fileName="代理商活动财务日报";
            }
            EasyExcelUtil.writeExcel(response,CustomerReportFinanceVo.class,records,fileName);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    @ApiOperation(value = "1客服部报表--财务日报-详情")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "isOwn", value = " 0所有   1只查自己",required = false, paramType = "query"),
            @ApiImplicitParam(name = "roleType", value = "角色类型",required = false, paramType = "query"),
            @ApiImplicitParam(name = "agentId", value = "代理商Id",required = false, paramType = "query"),
            @ApiImplicitParam(name = "agentPid", value = "代理商父Id",required = false, paramType = "query"),
            @ApiImplicitParam(name = "startTime", value = "开始时间",required = false, paramType = "query"),
            @ApiImplicitParam(name = "endTime", value = "结束时间",required = false, paramType = "query"),
            @ApiImplicitParam(name = "role", value = "角色 1客服下单，2代理商下单，3客户下单",required = false, paramType = "query"),
            @ApiImplicitParam(name = "userName", value = "用户名",required = false, paramType = "query"),
            @ApiImplicitParam(name = "mobile", value = "手机号",required = false, paramType = "query"),
            @ApiImplicitParam(name = "orderType", value = "订单类型 1正价 2代理活动 3秒杀活动",required = false, paramType = "query"),
            @ApiImplicitParam(name = "orderStatus", value = "订单状态  1全部总量 2实际总量 3退货总量 4断货总量 5取消总量 6瑕疵总量  7问题总量",required = false, paramType = "query"),
            @ApiImplicitParam(name = "actId", value = "活动Id",required = false, paramType = "query"),
            @ApiImplicitParam(name = "actName", value = "活动名字",required = false, paramType = "query"),
            @ApiImplicitParam(name = "sortField", value = "排序字段",required = false, paramType = "query"),
            @ApiImplicitParam(name = "sortType", value = "排序类型  asc正序  desc倒序",required = false, paramType = "query"),
            @ApiImplicitParam(name = "fromAgent", value = "是否来自代理后台  0否   1是",required = false, paramType = "query"),
    })
    @GetMapping("/customer/finance/detail")
    public Result<MPage<CustomerReportDetailVo>> customerFinanceDetail(Integer isOwn,
                                                                       Integer roleType,
                                                                       Long agentId,
                                                                       Long agentPid,
                                                                       String startTime,
                                                                       String endTime,
                                                                       String role,
                                                                       String userName,
                                                                       String mobile,
                                                                       Integer orderType,
                                                                       Integer orderStatus,
                                                                       Long actId,
                                                                       String actName,
                                                                       String sortField,
                                                                       String sortType,
                                                                       Integer fromAgent){
        IPage<CustomerReportDetailVo> page = reportCustomerService.customerFinanceDetail(isOwn,roleType, agentId,agentPid, startTime, endTime, role, userName, mobile,orderType,orderStatus,actId,actName, sortField, sortType, initMpPage());

        Map<String, Object> map = reportCustomerService.customerFinanceTotal(isOwn,roleType, agentId, agentPid,startTime, endTime, role, userName, mobile,orderType,orderStatus,actId,actName);
        if (null != fromAgent && 1 == fromAgent.intValue()){
            Long aid = AuthUtil.getAgentExt().getAid();
            List<CustomerReportDetailVo> records = page.getRecords();
            if (CollUtil.isNotEmpty(records)){
                for (CustomerReportDetailVo vo :records){
                    if(aid.longValue() != vo.getAgentId().longValue()){
                        vo.setContactPhone(CommonUtil.coverMobile(vo.getContactPhone()));
                    }
                }
            }
        }
        MPage<CustomerReportDetailVo> mPage = new MPage<>();
        BeanUtils.copyProperties(page,mPage);
        if (MapUtil.isEmpty(map)){
            map=new HashMap<>();
        }
        mPage.setMap(map);
        return ResultUtil.success(mPage);
    }
    @ApiOperation(value = "1客服部报表--财务日报-详情-导出excel")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "isOwn", value = " 0所有   1只查自己",required = false, paramType = "query"),
            @ApiImplicitParam(name = "roleType", value = "角色类型",required = false, paramType = "query"),
            @ApiImplicitParam(name = "agentId", value = "代理商Id",required = false, paramType = "query"),
            @ApiImplicitParam(name = "agentPid", value = "代理商父Id",required = false, paramType = "query"),
            @ApiImplicitParam(name = "startTime", value = "开始时间",required = false, paramType = "query"),
            @ApiImplicitParam(name = "endTime", value = "结束时间",required = false, paramType = "query"),
            @ApiImplicitParam(name = "role", value = "角色 1客服下单，2代理商下单，3客户下单",required = false, paramType = "query"),
            @ApiImplicitParam(name = "userName", value = "用户名",required = false, paramType = "query"),
            @ApiImplicitParam(name = "mobile", value = "手机号",required = false, paramType = "query"),
            @ApiImplicitParam(name = "orderType", value = "订单类型 1正价 2代理活动 3秒杀活动",required = false, paramType = "query"),
            @ApiImplicitParam(name = "orderStatus", value = "订单状态  1全部总量 2实际总量 3退货总量 4断货总量 5取消总量 6瑕疵总量  7问题总量",required = false, paramType = "query"),
            @ApiImplicitParam(name = "actId", value = "活动Id",required = false, paramType = "query"),
            @ApiImplicitParam(name = "actName", value = "活动名称",required = false, paramType = "query"),
            @ApiImplicitParam(name = "sortField", value = "排序字段",required = false, paramType = "query"),
            @ApiImplicitParam(name = "sortType", value = "排序类型  asc正序  desc倒序",required = false, paramType = "query"),
            @ApiImplicitParam(name = "fromAgent", value = "是否来自代理后台  0否   1是",required = false, paramType = "query"),
    })
    @GetMapping("/customer/finance/detail/excel")
//    @NoNeedAccess
    public void customerFinanceDetailExcel(Integer isOwn,
                                           Integer roleType,
                                           Long agentId,
                                           Long agentPid,
                                           String startTime,
                                           String endTime,
                                           String role,
                                           String userName,
                                           String mobile,
                                           Integer orderType,
                                           Integer orderStatus,
                                           Long actId,
                                           String actName,
                                           String sortField,
                                           String sortType,
                                           Integer fromAgent,
                                           HttpServletResponse response){
        IPage<CustomerReportDetailVo> page = reportCustomerService.customerFinanceDetail(isOwn,roleType, agentId,agentPid, startTime, endTime, role, userName, mobile,orderType,orderStatus,actId, actName,sortField, sortType, new Page(1,-1));
        List<CustomerReportDetailVo> records = page.getRecords();
        try {
            if (null != fromAgent && 1 == fromAgent.intValue()){
                Long aid = AuthUtil.getAgentExt().getAid();
                if (CollUtil.isNotEmpty(records)){
                    for (CustomerReportDetailVo vo :records){
                        if(aid.longValue() != vo.getAgentId().longValue()){
                            vo.setContactPhone(CommonUtil.coverMobile(vo.getContactPhone()));
                        }
                    }
                }
            }
            EasyExcelUtil.writeExcel(response,CustomerReportDetailVo.class,records,"订单明细");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    @ApiOperation(value = "1客服部报表--财务日报-个人业绩查看")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "roleType", value = "角色类型",required = false, paramType = "query"),
            @ApiImplicitParam(name = "agentId", value = "代理商Id",required = false, paramType = "query"),
            @ApiImplicitParam(name = "agentPid", value = "代理商父Id",required = false, paramType = "query"),
            @ApiImplicitParam(name = "startTime", value = "开始时间",required = false, paramType = "query"),
            @ApiImplicitParam(name = "endTime", value = "结束时间",required = false, paramType = "query"),
            @ApiImplicitParam(name = "orderType", value = "订单类型",required = false, paramType = "query"),
            @ApiImplicitParam(name = "actId", value = "活动Id",required = false, paramType = "query"),
            @ApiImplicitParam(name = "actName", value = "活动名称",required = false, paramType = "query"),
            @ApiImplicitParam(name = "sortField", value = "排序字段",required = false, paramType = "query"),
            @ApiImplicitParam(name = "sortType", value = "排序类型  asc正序  desc倒序",required = false, paramType = "query"),
    })
    @GetMapping("/customer/finance/person")
    public Result<IPage<CustomerReportFinanceVo>> customerFinancePerson(Integer roleType,Long agentId,Long agentPid,String startTime,String endTime,Integer orderType,Long actId,String actName,String sortField,String sortType){
        IPage<CustomerReportFinanceVo> page = reportCustomerService.customerFinancePerson(roleType, agentId,agentPid, startTime, endTime, orderType, actId,actName,sortField, sortType,initMpPage());
        return ResultUtil.success(page);
    }
    @ApiOperation(value = "1客服部报表--财务日报-个人业绩查看-导出")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "roleType", value = "角色类型",required = false, paramType = "query"),
            @ApiImplicitParam(name = "agentId", value = "代理商Id",required = false, paramType = "query"),
            @ApiImplicitParam(name = "agentPid", value = "代理商父Id",required = false, paramType = "query"),
            @ApiImplicitParam(name = "startTime", value = "开始时间",required = false, paramType = "query"),
            @ApiImplicitParam(name = "endTime", value = "结束时间",required = false, paramType = "query"),
            @ApiImplicitParam(name = "orderType", value = "订单类型",required = false, paramType = "query"),
            @ApiImplicitParam(name = "actId", value = "活动Id",required = false, paramType = "query"),
            @ApiImplicitParam(name = "actName", value = "活动名称",required = false, paramType = "query"),
            @ApiImplicitParam(name = "sortField", value = "排序字段",required = false, paramType = "query"),
            @ApiImplicitParam(name = "sortType", value = "排序类型  asc正序  desc倒序",required = false, paramType = "query"),
    })
    @GetMapping("/customer/finance/person/excel")
    public void customerFinancePersonExcel(Integer roleType,Long agentId,Long agentPid,String startTime,String endTime,Integer orderType,Long actId,String actName,String sortField,String sortType,HttpServletResponse response){
        IPage<CustomerReportFinanceVo> page = reportCustomerService.customerFinancePerson(roleType, agentId,agentPid, startTime, endTime, orderType, actId,actName,sortField, sortType, new Page(1,-1));
        List<CustomerReportFinanceVo> records = page.getRecords();
        try {
            EasyExcelUtil.writeExcel(response,CustomerReportFinanceVo.class,records,"个人业绩");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    @ApiOperation(value = "2客服部报表--折扣日报")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "roleType", value = "角色类型",required = false, paramType = "query"),
            @ApiImplicitParam(name = "agentId", value = "代理商Id",required = false, paramType = "query"),
            @ApiImplicitParam(name = "agentPid", value = "代理商父Id",required = false, paramType = "query"),
            @ApiImplicitParam(name = "pRole", value = "代理商父角色",required = false, paramType = "query"),
            @ApiImplicitParam(name = "startTime", value = "开始时间",required = false, paramType = "query"),
            @ApiImplicitParam(name = "endTime", value = "结束时间",required = false, paramType = "query"),
            @ApiImplicitParam(name = "discount", value = "折扣",required = false, paramType = "query"),
            @ApiImplicitParam(name = "groupType", value = "分组方式  1客服   2折扣方式",required = false, paramType = "query"),
            @ApiImplicitParam(name = "sortField", value = "排序字段",required = false, paramType = "query"),
            @ApiImplicitParam(name = "sortType", value = "排序类型  asc正序  desc倒序",required = false, paramType = "query"),
    })
    @GetMapping("/customer/discount")
    public Result<IPage<CustomerReportDiscountVo>> customerDiscount(Integer roleType, Long agentId,Long agentPid,Integer pRole, String startTime, String endTime, BigDecimal discount, Integer groupType, String sortField, String sortType){
        IPage<CustomerReportDiscountVo> page = reportCustomerService.customerDiscount(roleType, agentId, agentPid,pRole,startTime, endTime, discount, groupType, sortField, sortType, initMpPage());
        return ResultUtil.success(page);
    }

    @ApiOperation(value = "2客服部报表--折扣日报-获取所有折扣")
    @GetMapping("/discount/list")
    public Result discountList(){
        List<BigDecimal> discountList = reportCustomerService.discountList();
        return ResultUtil.success(discountList);
    }

    @ApiOperation(value = "2客服部报表--折扣日报-导出excel")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "roleType", value = "角色类型",required = false, paramType = "query"),
            @ApiImplicitParam(name = "agentId", value = "代理商Id",required = false, paramType = "query"),
            @ApiImplicitParam(name = "agentPid", value = "代理商父Id",required = false, paramType = "query"),
            @ApiImplicitParam(name = "pRole", value = "代理商父角色",required = false, paramType = "query"),
            @ApiImplicitParam(name = "startTime", value = "开始时间",required = false, paramType = "query"),
            @ApiImplicitParam(name = "endTime", value = "结束时间",required = false, paramType = "query"),
            @ApiImplicitParam(name = "discount", value = "折扣",required = false, paramType = "query"),
            @ApiImplicitParam(name = "groupType", value = "分组方式  1客服   2折扣方式",required = false, paramType = "query"),
            @ApiImplicitParam(name = "sortField", value = "排序字段",required = false, paramType = "query"),
            @ApiImplicitParam(name = "sortType", value = "排序类型  asc正序  desc倒序",required = false, paramType = "query"),
    })
    @GetMapping("/customer/discount/excel")
    @NoNeedAccess
    public void customerDiscountExcel(Integer roleType, Long agentId,Long agentPid,Integer pRole, String startTime, String endTime, BigDecimal discount, Integer groupType, String sortField, String sortType,HttpServletResponse response){
        IPage<CustomerReportDiscountVo> page = reportCustomerService.customerDiscount(roleType, agentId, agentPid,pRole,startTime, endTime, discount, groupType, sortField, sortType, new Page(1,-1));
        List<CustomerReportDiscountVo> records = page.getRecords();
        try {
            EasyExcelUtil.writeExcel(response,CustomerReportDiscountVo.class,records,"折扣日报");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    @ApiOperation(value = "2客服部报表--折扣日报-查看个人")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "roleType", value = "角色类型",required = false, paramType = "query"),
            @ApiImplicitParam(name = "agentId", value = "代理商Id",required = false, paramType = "query"),
            @ApiImplicitParam(name = "agentPid", value = "代理商父Id",required = false, paramType = "query"),
            @ApiImplicitParam(name = "startTime", value = "开始时间",required = false, paramType = "query"),
            @ApiImplicitParam(name = "endTime", value = "结束时间",required = false, paramType = "query"),
            @ApiImplicitParam(name = "discount", value = "折扣",required = false, paramType = "query")
    })
    @GetMapping("/customer/discount/person")
    public Result<IPage<CustomerReportDiscountPersonVo>> customerDiscountPerson(Integer roleType, Long agentId,Long agentPid, String startTime, String endTime, BigDecimal discount){
        IPage<CustomerReportDiscountPersonVo> page = reportCustomerService.customerDiscountPerson(roleType, agentId,agentPid, startTime, endTime, discount, initMpPage());
        return ResultUtil.success(page);
    }
    @ApiOperation(value = "2客服部报表--折扣日报-查看个人-导出")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "roleType", value = "角色类型",required = false, paramType = "query"),
            @ApiImplicitParam(name = "agentId", value = "代理商Id",required = false, paramType = "query"),
            @ApiImplicitParam(name = "agentPid", value = "代理商父Id",required = false, paramType = "query"),
            @ApiImplicitParam(name = "startTime", value = "开始时间",required = false, paramType = "query"),
            @ApiImplicitParam(name = "endTime", value = "结束时间",required = false, paramType = "query"),
            @ApiImplicitParam(name = "discount", value = "折扣",required = false, paramType = "query")
    })
    @GetMapping("/customer/discount/person/excel")
    public void customerDiscountPersonExcel(Integer roleType, Long agentId,Long agentPid, String startTime, String endTime, BigDecimal discount,HttpServletResponse response){
        IPage<CustomerReportDiscountPersonVo> page = reportCustomerService.customerDiscountPerson(roleType, agentId,agentPid, startTime, endTime, discount, new Page(1,-1));
        List<CustomerReportDiscountPersonVo> records = page.getRecords();
        try {
            EasyExcelUtil.writeExcel(response,CustomerReportDiscountPersonVo.class,records,"折扣日报-查看个人");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    @ApiOperation(value = "2客服部报表--折扣日报-广告列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "isOwn", value = "1自己 0团队 2客服",required = false, paramType = "query"),
            @ApiImplicitParam(name = "roleType", value = "角色类型",required = false, paramType = "query"),
            @ApiImplicitParam(name = "agentId", value = "代理商Id",required = false, paramType = "query"),
            @ApiImplicitParam(name = "plateformName", value = "广告平台",required = false, paramType = "query"),
            @ApiImplicitParam(name = "chatNum", value = "公众号",required = false, paramType = "query"),
            @ApiImplicitParam(name = "directorName", value = "广告员",required = false, paramType = "query"),
            @ApiImplicitParam(name = "orderedAgent", value = "代理商",required = false, paramType = "query"),
            @ApiImplicitParam(name = "payTimeStart", value = "支付开始时间",required = false, paramType = "query"),
            @ApiImplicitParam(name = "payTimeEnd", value = "支付结束时间",required = false, paramType = "query"),
            @ApiImplicitParam(name = "launchDateStart", value = "投放开始时间",required = false, paramType = "query"),
            @ApiImplicitParam(name = "launchDateEnd", value = "投放结束时间",required = false, paramType = "query"),
            @ApiImplicitParam(name = "endOrderDateStart", value = "推送开始时间",required = false, paramType = "query"),
            @ApiImplicitParam(name = "endOrderDateEnd", value = "推送结束时间",required = false, paramType = "query"),
    })
    @GetMapping("/customer/discount/ads")
    public Result<IPage<CustomerAdvertisementDetailVo>> customerDiscountAds(Integer isOwn,Integer roleType,Long agentId,
            String plateformName, String chatNum, String directorName, String orderedAgent
            , String payTimeStart, String payTimeEnd, String launchDateStart, String launchDateEnd, String endOrderDateStart, String endOrderDateEnd
            ,String sortField, String sortType){
        IPage<CustomerAdvertisementDetailVo> page = reportCustomerService.customerDiscountAds(isOwn,roleType,agentId,plateformName
                ,chatNum,directorName,orderedAgent,payTimeStart,payTimeEnd,launchDateStart,launchDateEnd,endOrderDateStart,endOrderDateEnd,sortField,sortType,initMpPage());
        return ResultUtil.success(page);
    }
    @ApiOperation(value = "2客服部报表--折扣日报-广告列表-导出excel")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "isOwn", value = "1自己 0团队 2客服",required = false, paramType = "query"),
            @ApiImplicitParam(name = "roleType", value = "角色类型",required = false, paramType = "query"),
            @ApiImplicitParam(name = "agentId", value = "代理商Id",required = false, paramType = "query"),
            @ApiImplicitParam(name = "plateformName", value = "广告平台",required = false, paramType = "query"),
            @ApiImplicitParam(name = "chatNum", value = "公众号",required = false, paramType = "query"),
            @ApiImplicitParam(name = "directorName", value = "广告员",required = false, paramType = "query"),
            @ApiImplicitParam(name = "orderedAgent", value = "代理商",required = false, paramType = "query"),
            @ApiImplicitParam(name = "payTimeStart", value = "支付开始时间",required = false, paramType = "query"),
            @ApiImplicitParam(name = "payTimeEnd", value = "支付结束时间",required = false, paramType = "query"),
            @ApiImplicitParam(name = "launchDateStart", value = "投放开始时间",required = false, paramType = "query"),
            @ApiImplicitParam(name = "launchDateEnd", value = "投放结束时间",required = false, paramType = "query"),
            @ApiImplicitParam(name = "endOrderDateStart", value = "推送开始时间",required = false, paramType = "query"),
            @ApiImplicitParam(name = "endOrderDateEnd", value = "推送结束时间",required = false, paramType = "query"),
    })
    @GetMapping("/customer/discount/ads/excel")
    @NoNeedAccess
    public void customerDiscountAdsExcel(Integer isOwn,Integer roleType,Long agentId,
                                         String plateformName, String chatNum, String directorName, String orderedAgent
            , String payTimeStart, String payTimeEnd, String launchDateStart, String launchDateEnd, String endOrderDateStart, String endOrderDateEnd
            ,String sortField, String sortType,HttpServletResponse response){
        IPage<CustomerAdvertisementDetailVo> page = reportCustomerService.customerDiscountAds(isOwn,roleType,agentId,plateformName
                ,chatNum,directorName,orderedAgent,payTimeStart,payTimeEnd,launchDateStart,launchDateEnd,endOrderDateStart,endOrderDateEnd,sortField,sortType,new Page(1,-1));
        List<CustomerAdvertisementDetailVo> records = page.getRecords();
        try {
            EasyExcelUtil.writeExcel(response,CustomerAdvertisementDetailVo.class,records,"广告明细");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    @ApiOperation(value = "5客服部报表--秒杀活动财务日报")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "roleType", value = "角色类型",required = false, paramType = "query"),
            @ApiImplicitParam(name = "agentId", value = "代理商Id",required = false, paramType = "query"),
            @ApiImplicitParam(name = "agentPid", value = "代理商父Id",required = false, paramType = "query"),
            @ApiImplicitParam(name = "pRole", value = "代理商父角色",required = false, paramType = "query"),
            @ApiImplicitParam(name = "startTime", value = "开始时间",required = false, paramType = "query"),
            @ApiImplicitParam(name = "endTime", value = "结束时间",required = false, paramType = "query"),
            @ApiImplicitParam(name = "actId", value = "活动Id",required = false, paramType = "query"),
            @ApiImplicitParam(name = "actName", value = "活动名称",required = false, paramType = "query"),
            @ApiImplicitParam(name = "sortField", value = "排序字段",required = false, paramType = "query"),
            @ApiImplicitParam(name = "sortType", value = "排序类型  asc正序  desc倒序",required = false, paramType = "query"),
    })
    @GetMapping("/customer/seckill")
    public Result<IPage<CustomerSeckillDayReportVo>> customerSeckill(Integer roleType,Long agentId,Long agentPid,Integer pRole, String startTime,String endTime,Long actId,String actName,String sortField,String sortType){
        IPage<CustomerSeckillDayReportVo> page = reportCustomerService.customerSeckill(roleType, agentId,agentPid ,pRole,startTime, endTime, actId, actName,sortField, sortType, initMpPage());
        return ResultUtil.success(page);
    }
    @ApiOperation(value = "5客服部报表--秒杀活动财务日报-导出excel")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "roleType", value = "角色类型",required = false, paramType = "query"),
            @ApiImplicitParam(name = "agentId", value = "代理商Id",required = false, paramType = "query"),
            @ApiImplicitParam(name = "agentPid", value = "代理商父Id",required = false, paramType = "query"),
            @ApiImplicitParam(name = "pRole", value = "代理商父角色",required = false, paramType = "query"),
            @ApiImplicitParam(name = "startTime", value = "开始时间",required = false, paramType = "query"),
            @ApiImplicitParam(name = "endTime", value = "结束时间",required = false, paramType = "query"),
            @ApiImplicitParam(name = "actId", value = "活动Id",required = false, paramType = "query"),
            @ApiImplicitParam(name = "actName", value = "活动名称",required = false, paramType = "query"),
            @ApiImplicitParam(name = "sortField", value = "排序字段",required = false, paramType = "query"),
            @ApiImplicitParam(name = "sortType", value = "排序类型  asc正序  desc倒序",required = false, paramType = "query"),
    })
    @GetMapping("/customer/seckill/excel")
    @NoNeedAccess
    public void customerSeckillExcel(Integer roleType,Long agentId,Long agentPid,Integer pRole,String startTime,String endTime,Long actId,String actName,String sortField,String sortType,HttpServletResponse response){
        IPage<CustomerSeckillDayReportVo> page = reportCustomerService.customerSeckill(roleType, agentId,agentPid,pRole, startTime, endTime, actId,actName, sortField, sortType, new Page(1,-1));
        List<CustomerSeckillDayReportVo> records = page.getRecords();
        try {
            EasyExcelUtil.writeExcel(response,CustomerSeckillDayReportVo.class,records,"秒杀活动日报");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    @ApiOperation(value = "6客服部报表--客户报表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "contactUser", value = "姓名",required = false, paramType = "query"),
            @ApiImplicitParam(name = "contactPhone", value = "收货手机号",required = false, paramType = "query"),
            @ApiImplicitParam(name = "isRepeat", value = "是否重复购买 0 不重复  1重复",required = false, paramType = "query"),
            @ApiImplicitParam(name = "startTime", value = "开始时间",required = false, paramType = "query"),
            @ApiImplicitParam(name = "endTime", value = "结束时间",required = false, paramType = "query"),
            @ApiImplicitParam(name = "filter", value = "筛选条件：可以根据 1-十日内重复购买，2-一个月内重复购买，3- 一个季度重复购买，4- 一年内重复购买",required = false, paramType = "query"),
            @ApiImplicitParam(name = "orderType", value = "订单类型",required = false, paramType = "query"),
            @ApiImplicitParam(name = "buyNumMin", value = "购买数量区间最小值",required = false, paramType = "query"),
            @ApiImplicitParam(name = "buyNumMax", value = "购买数量区间最大值",required = false, paramType = "query"),
            @ApiImplicitParam(name = "buyTimes", value = "购买数量 0 从未购买  1购买过",required = false, paramType = "query"),
            @ApiImplicitParam(name = "sortField", value = "排序字段",required = false, paramType = "query"),
            @ApiImplicitParam(name = "sortType", value = "排序类型  asc正序  desc倒序",required = false, paramType = "query"),
    })
    @GetMapping("/customer/user/report")
    public Result<IPage<CustomerUserReportVo>> customerUserReport(String contactUser, String contactPhone, Integer isRepeat, String startTime, String endTime, Integer filter, Integer buyNumMin, Integer buyNumMax, Integer buyTimes, String orderType,String sortField,String sortType){
        if (filter!=null){
            endTime = DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss");
            //1一周内重复购买
            if (filter==1){
                Date start = DateUtils.addWeeks(new Date(), -1);
                startTime=DateUtil.format(start, "yyyy-MM-dd HH:mm:ss");
            }
            //2-一个月内重复购买
            if (filter==2){
                Date start = DateUtils.addMonths(new Date(), -1);
                startTime=DateUtil.format(start, "yyyy-MM-dd HH:mm:ss");
            }
            //3一季度内重复购买
            if (filter==3){
                Date start = DateUtils.addMonths(new Date(), -3);
                startTime=DateUtil.format(start, "yyyy-MM-dd HH:mm:ss");
            }
            //4- 一年内重复购买
            if (filter==4){
                Date start = DateUtils.addYears(new Date(), -1);
                startTime=DateUtil.format(start, "yyyy-MM-dd HH:mm:ss");
            }
            isRepeat=1;
        }
        IPage<CustomerUserReportVo> page = reportCustomerService.customerUserReport(contactUser, contactPhone, isRepeat, startTime, endTime, filter, buyNumMin, buyNumMax, buyTimes, orderType,sortField,sortType, initMpPage());
        return ResultUtil.success(page);
    }
    @ApiOperation(value = "6客服部报表--客户报表-导出excel")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "contactUser", value = "姓名",required = false, paramType = "query"),
            @ApiImplicitParam(name = "contactPhone", value = "收货手机号",required = false, paramType = "query"),
            @ApiImplicitParam(name = "isRepeat", value = "是否重复购买 0 不重复  1重复",required = false, paramType = "query"),
            @ApiImplicitParam(name = "startTime", value = "开始时间",required = false, paramType = "query"),
            @ApiImplicitParam(name = "endTime", value = "结束时间",required = false, paramType = "query"),
            @ApiImplicitParam(name = "filter", value = "筛选条件：可以根据 1-十日内重复购买，2-一个月内重复购买，3- 一个季度重复购买，4- 一年内重复购买",required = false, paramType = "query"),
            @ApiImplicitParam(name = "orderType", value = "订单类型",required = false, paramType = "query"),
            @ApiImplicitParam(name = "buyNumMin", value = "购买数量区间最小值",required = false, paramType = "query"),
            @ApiImplicitParam(name = "buyNumMax", value = "购买数量区间最大值",required = false, paramType = "query"),
            @ApiImplicitParam(name = "buyTimes", value = "购买数量 0 从未购买  1购买过",required = false, paramType = "query"),
            @ApiImplicitParam(name = "sortField", value = "排序字段",required = false, paramType = "query"),
            @ApiImplicitParam(name = "sortType", value = "排序类型  asc正序  desc倒序",required = false, paramType = "query"),
    })
    @GetMapping("/customer/user/report/excel")
    @NoNeedAccess
    public void customerUserReportExcel(String contactUser, String contactPhone, Integer isRepeat, String startTime, String endTime, Integer filter, Integer buyNumMin, Integer buyNumMax, Integer buyTimes, String orderType,String sortField,String sortType,HttpServletResponse response){
        if (filter!=null){
            endTime = DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss");
            //1一周内重复购买
            if (filter==1){
                Date start = DateUtils.addWeeks(new Date(), -1);
                startTime=DateUtil.format(start, "yyyy-MM-dd HH:mm:ss");
            }
            //2-一个月内重复购买
            if (filter==2){
                Date start = DateUtils.addMonths(new Date(), -1);
                startTime=DateUtil.format(start, "yyyy-MM-dd HH:mm:ss");
            }
            //3一季度内重复购买
            if (filter==3){
                Date start = DateUtils.addMonths(new Date(), -3);
                startTime=DateUtil.format(start, "yyyy-MM-dd HH:mm:ss");
            }
            //4- 一年内重复购买
            if (filter==4){
                Date start = DateUtils.addYears(new Date(), -1);
                startTime=DateUtil.format(start, "yyyy-MM-dd HH:mm:ss");
            }
            isRepeat=1;
        }
        IPage<CustomerUserReportVo> page = reportCustomerService.customerUserReport(contactUser, contactPhone, isRepeat, startTime, endTime, filter, buyNumMin, buyNumMax, buyTimes, orderType,sortField,sortType, new Page(1,-1));
        try {
            EasyExcelUtil.writeExcel(response,CustomerUserReportVo.class,page.getRecords(),"客户报表");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    @ApiOperation(value = "6客服部报表--客户报表-查看购买记录")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "buyerId", value = "用户Id",required = true, paramType = "query"),
            @ApiImplicitParam(name = "orderFrom", value = "下单来源 1客服下单，2代理商下单，3客户下单",required = false, paramType = "query"),
            @ApiImplicitParam(name = "goodsName", value = "商品名称",required = false, paramType = "query"),
            @ApiImplicitParam(name = "orderSn", value = "订单号",required = false, paramType = "query"),
            @ApiImplicitParam(name = "agentName", value = "代理商",required = false, paramType = "query"),
            @ApiImplicitParam(name = "startTime", value = "下单开始时间",required = false, paramType = "query"),
            @ApiImplicitParam(name = "endTime", value = "下单结束时间",required = false, paramType = "query")
    })
    @GetMapping("/customer/user/report/buy/log")
    public  Result<IPage<CustomerUserReportBuyLogVo>> customerUserReportBuyLog(Long buyerId,Integer orderFrom,String goodsName,String customerName,String orderSn,String agentName,String startTime,String endTime){
        IPage<CustomerUserReportBuyLogVo> page = reportCustomerService.customerUserReportBuyLog(buyerId, orderFrom, goodsName, customerName, orderSn, agentName, startTime, endTime, initMpPage());
        return ResultUtil.success(page);
    }
    @ApiOperation(value = "6客服部报表--客户报表-查看购买记录-导出excel")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "buyerId", value = "用户Id",required = true, paramType = "query"),
            @ApiImplicitParam(name = "orderFrom", value = "下单来源 1客服下单，2代理商下单，3客户下单",required = false, paramType = "query"),
            @ApiImplicitParam(name = "goodsName", value = "商品名称",required = false, paramType = "query"),
            @ApiImplicitParam(name = "orderSn", value = "订单号",required = false, paramType = "query"),
            @ApiImplicitParam(name = "agentName", value = "代理商",required = false, paramType = "query"),
            @ApiImplicitParam(name = "startTime", value = "下单开始时间",required = false, paramType = "query"),
            @ApiImplicitParam(name = "endTime", value = "下单结束时间",required = false, paramType = "query")
    })
    @GetMapping("/customer/user/report/buy/log/excel")
    @NoNeedAccess
    public  void customerUserReportBuyLogExcel(Long buyerId,Integer orderFrom,String goodsName,String customerName,String orderSn,String agentName,String startTime,String endTime,HttpServletResponse response){
        IPage<CustomerUserReportBuyLogVo> page = reportCustomerService.customerUserReportBuyLog(buyerId, orderFrom, goodsName, customerName, orderSn, agentName, startTime, endTime, new Page(1,-1));
        try {
            EasyExcelUtil.writeExcel(response,CustomerUserReportBuyLogVo.class,page.getRecords(),"客户报表-购买记录");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    @ApiOperation(value = "6-2客服部报表--客户报表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "contactUser", value = "姓名",required = false, paramType = "query"),
            @ApiImplicitParam(name = "contactPhone", value = "收货手机号",required = false, paramType = "query"),
            @ApiImplicitParam(name = "startTime", value = "开始时间",required = false, paramType = "query"),
            @ApiImplicitParam(name = "endTime", value = "结束时间",required = false, paramType = "query"),
            @ApiImplicitParam(name = "orderType", value = "订单类型",required = false, paramType = "query"),
            @ApiImplicitParam(name = "buyNumMin", value = "购买数量区间最小值",required = false, paramType = "query"),
            @ApiImplicitParam(name = "buyNumMax", value = "购买数量区间最大值",required = false, paramType = "query"),
            @ApiImplicitParam(name = "sortField", value = "排序字段",required = false, paramType = "query"),
            @ApiImplicitParam(name = "isRepeat2", value = "是否重复购买  0否  1是",required = false, paramType = "query"),
            @ApiImplicitParam(name = "isHave", value = "十日之内是否有购买记录  0无  1有",required = false, paramType = "query"),
            @ApiImplicitParam(name = "sortType", value = "排序类型  asc正序  desc倒序",required = false, paramType = "query"),
    })
    @GetMapping("/customer/user/report2")
    @NoNeedAccess
    public Result<IPage<CustomerUserReportVo>> customerUserReport2(String contactUser, String contactPhone, String startTime, String endTime, Integer buyNumMin, Integer buyNumMax, String orderType,String sortField,String sortType,Integer isRepeat2,Integer isHave){
        IPage<CustomerUserReportVo> page = reportCustomerService.customerUserReport2(contactUser, contactPhone, startTime, endTime, buyNumMin, buyNumMax, orderType,sortField,sortType, isRepeat2,isHave, initMpPage());
        return ResultUtil.success(page);
    }
    @ApiOperation(value = "6-2客服部报表--客户报表-导出excel2")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "contactUser", value = "姓名",required = false, paramType = "query"),
            @ApiImplicitParam(name = "contactPhone", value = "收货手机号",required = false, paramType = "query"),
            @ApiImplicitParam(name = "startTime", value = "开始时间",required = false, paramType = "query"),
            @ApiImplicitParam(name = "endTime", value = "结束时间",required = false, paramType = "query"),
            @ApiImplicitParam(name = "orderType", value = "订单类型",required = false, paramType = "query"),
            @ApiImplicitParam(name = "buyNumMin", value = "购买数量区间最小值",required = false, paramType = "query"),
            @ApiImplicitParam(name = "buyNumMax", value = "购买数量区间最大值",required = false, paramType = "query"),
            @ApiImplicitParam(name = "sortField", value = "排序字段",required = false, paramType = "query"),
            @ApiImplicitParam(name = "isRepeat2", value = "是否重复购买  0否  1是",required = false, paramType = "query"),
            @ApiImplicitParam(name = "isHave", value = "十日之内是否有购买记录  0无  1有",required = false, paramType = "query"),
            @ApiImplicitParam(name = "sortType", value = "排序类型  asc正序  desc倒序",required = false, paramType = "query"),
    })
    @GetMapping("/customer/user/report/excel2")
    @NoNeedAccess
    public void customerUserReportExcel2(String contactUser, String contactPhone, String startTime, String endTime,Integer buyNumMin, Integer buyNumMax, String orderType,String sortField,String sortType,Integer isRepeat2,Integer isHave,HttpServletResponse response){
        IPage<CustomerUserReportVo> page = reportCustomerService.customerUserReport2(contactUser, contactPhone, startTime, endTime, buyNumMin, buyNumMax, orderType,sortField,sortType,isRepeat2,isHave, new Page(1,-1));
        try {
            EasyExcelUtil.writeExcel(response,CustomerUserReportVo.class,page.getRecords(),"客户报表");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    @ApiOperation(value = "6-2客服部报表--客户报表-查看购买记录")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "buyerId", value = "用户Id",required = true, paramType = "query"),
            @ApiImplicitParam(name = "contactPhone", value = "收货手机号",required = false, paramType = "query"),
            @ApiImplicitParam(name = "orderFrom", value = "下单来源 1客服下单，2代理商下单，3客户下单",required = false, paramType = "query"),
            @ApiImplicitParam(name = "goodsName", value = "商品名称",required = false, paramType = "query"),
            @ApiImplicitParam(name = "orderSn", value = "订单号",required = false, paramType = "query"),
            @ApiImplicitParam(name = "agentName", value = "代理商",required = false, paramType = "query"),
            @ApiImplicitParam(name = "startTime", value = "下单开始时间",required = false, paramType = "query"),
            @ApiImplicitParam(name = "endTime", value = "下单结束时间",required = false, paramType = "query")
    })
    @GetMapping("/customer/user/report/buy/log2")
    public  Result<IPage<CustomerUserReportBuyLogVo>> customerUserReportBuyLog2(Long buyerId,String contactPhone,Integer orderFrom,String goodsName,String customerName,String orderSn,String agentName,String startTime,String endTime){
        IPage<CustomerUserReportBuyLogVo> page = reportCustomerService.customerUserReportBuyLog2(buyerId,contactPhone, orderFrom, goodsName, customerName, orderSn, agentName, startTime, endTime, initMpPage());
        return ResultUtil.success(page);
    }

    @ApiOperation(value = "6-2客服部报表--客户报表-查看购买记录-导出excel")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "buyerId", value = "用户Id",required = true, paramType = "query"),
            @ApiImplicitParam(name = "contactPhone", value = "收货手机号",required = false, paramType = "query"),
            @ApiImplicitParam(name = "orderFrom", value = "下单来源 1客服下单，2代理商下单，3客户下单",required = false, paramType = "query"),
            @ApiImplicitParam(name = "goodsName", value = "商品名称",required = false, paramType = "query"),
            @ApiImplicitParam(name = "orderSn", value = "订单号",required = false, paramType = "query"),
            @ApiImplicitParam(name = "agentName", value = "代理商",required = false, paramType = "query"),
            @ApiImplicitParam(name = "startTime", value = "下单开始时间",required = false, paramType = "query"),
            @ApiImplicitParam(name = "endTime", value = "下单结束时间",required = false, paramType = "query")
    })
    @GetMapping("/customer/user/report/buy/log/excel2")
    @NoNeedAccess
    public  void customerUserReportBuyLogExcel2(Long buyerId,String contactPhone,Integer orderFrom,String goodsName,String customerName,String orderSn,String agentName,String startTime,String endTime,HttpServletResponse response){
        IPage<CustomerUserReportBuyLogVo> page = reportCustomerService.customerUserReportBuyLog2(buyerId,contactPhone, orderFrom, goodsName, customerName, orderSn, agentName, startTime, endTime, new Page(1,-1));
        try {
            EasyExcelUtil.writeExcel(response,CustomerUserReportBuyLogVo.class,page.getRecords(),"客户报表-购买记录");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }


    @ApiOperation(value = "7客服部报表--秒杀活动报表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "role", value = "角色 1客服下单，2代理商下单，3客户下单",required = false, paramType = "query"),
            @ApiImplicitParam(name = "buyer", value = "用户名",required = false, paramType = "query"),
            @ApiImplicitParam(name = "actId", value = "活动Id",required = false, paramType = "query"),
            @ApiImplicitParam(name = "startTime", value = "开始时间",required = false, paramType = "query"),
            @ApiImplicitParam(name = "endTime", value = "结束时间",required = false, paramType = "query"),
            @ApiImplicitParam(name = "actName", value = "活动名称",required = false, paramType = "query"),
            @ApiImplicitParam(name = "mobile", value = "手机号",required = false, paramType = "query"),
    })
    @GetMapping("/customer/seckill/report")
    public Result<IPage<CustomerSeckillReportVo>> customerSeckillReport(Integer role,String buyer,Long actId,String startTime,String endTime,String actName,String mobile){
        IPage<CustomerSeckillReportVo> page = reportCustomerService.customerSeckillReport(role, buyer, OrderTypeEnum.SECKILL.getValue(), actId, startTime, endTime,actName,mobile, initMpPage());
        return ResultUtil.success(page);
    }
    @ApiOperation(value = "7客服部报表--秒杀活动报表-导出excel")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "role", value = "角色 1客服下单，2代理商下单，3客户下单",required = false, paramType = "query"),
            @ApiImplicitParam(name = "buyer", value = "用户名",required = false, paramType = "query"),
            @ApiImplicitParam(name = "orderType", value = "订单类型 1正价订单；2代理商活动订单；3秒杀活动订单 ",required = false, paramType = "query"),
            @ApiImplicitParam(name = "actId", value = "活动Id",required = false, paramType = "query"),
            @ApiImplicitParam(name = "startTime", value = "开始时间",required = false, paramType = "query"),
            @ApiImplicitParam(name = "endTime", value = "结束时间",required = false, paramType = "query"),
            @ApiImplicitParam(name = "actName", value = "活动名称",required = false, paramType = "query"),
            @ApiImplicitParam(name = "mobile", value = "手机号",required = false, paramType = "query"),
    })
    @GetMapping("/customer/seckill/report/excel")
    @NoNeedAccess
    public void customerSeckillReportExcel(Integer role,String buyer,Integer orderType,Long actId,String startTime,String endTime,String actName,String mobile,HttpServletResponse response){
        IPage<CustomerSeckillReportVo> page = reportCustomerService.customerSeckillReport(role, buyer, OrderTypeEnum.SECKILL.getValue(), actId, startTime, endTime,actName,mobile, new Page(1,-1));
        try {
            EasyExcelUtil.writeExcel(response,CustomerSeckillReportVo.class,page.getRecords(),"秒杀活动报表");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    @ApiOperation(value = "8客服部报表--正价销售报表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "agentName", value = "代理商名称",required = false, paramType = "query"),
            @ApiImplicitParam(name = "startTime", value = "开始时间",required = false, paramType = "query"),
            @ApiImplicitParam(name = "endTime", value = "结束时间",required = false, paramType = "query"),
            @ApiImplicitParam(name = "sortField", value = "排序字段",required = false, paramType = "query"),
            @ApiImplicitParam(name = "sortType", value = "排序类型  asc正序  desc倒序",required = false, paramType = "query"),
            @ApiImplicitParam(name = "orderType", value = "订单类型 1正价订单 2 代理商活动订单 3 秒杀订单",required = false, paramType = "query")
    })
    @GetMapping("/customer/regular/report")
    public Result<IPage<CustomerReportRegularVo>> customerReportRegular(String agentName,String startTime,String endTime,String sortField,String sortType,Integer orderType){
        IPage<CustomerReportRegularVo> page = reportCustomerService.customerReportRegular(agentName, startTime, endTime, sortField, sortType,orderType, initMpPage());
        return ResultUtil.success(page);
    }
    @ApiOperation(value = "8客服部报表--正价销售报表-导出excel")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "agentName", value = "代理商名称",required = false, paramType = "query"),
            @ApiImplicitParam(name = "startTime", value = "开始时间",required = false, paramType = "query"),
            @ApiImplicitParam(name = "endTime", value = "结束时间",required = false, paramType = "query"),
            @ApiImplicitParam(name = "sortField", value = "排序字段",required = false, paramType = "query"),
            @ApiImplicitParam(name = "sortType", value = "排序类型  asc正序  desc倒序",required = false, paramType = "query"),
            @ApiImplicitParam(name = "orderType", value = "订单类型 1正价订单 2 代理商活动订单 3 秒杀订单",required = false, paramType = "query")
    })
    @GetMapping("/customer/regular/report/excel")
    @NoNeedAccess
    public void customerReportRegularExcel(String agentName,String startTime,String endTime,String sortField,String sortType,Integer orderType,HttpServletResponse response){
        IPage<CustomerReportRegularVo> page = reportCustomerService.customerReportRegular(agentName, startTime, endTime, sortField, sortType,orderType, new Page(1,-1));
        try {
            EasyExcelUtil.writeExcel(response,CustomerReportRegularVo.class,page.getRecords(),"销售报表");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    @ApiOperation(value = "9客服部报表--退货报表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "roleType", value = "角色类型",required = false, paramType = "query"),
            @ApiImplicitParam(name = "agentId", value = "代理商Id",required = false, paramType = "query"),
            @ApiImplicitParam(name = "agentPid", value = "代理商父Id",required = false, paramType = "query"),
            @ApiImplicitParam(name = "pRole", value = "代理商父角色",required = false, paramType = "query"),
            @ApiImplicitParam(name = "userName", value = "用户名",required = false, paramType = "query"),
            @ApiImplicitParam(name = "actId", value = "活动Id",required = false, paramType = "query"),
            @ApiImplicitParam(name = "orderType", value = "订单类型 1正价订单；2代理商活动订单；3秒杀活动订单",required = false, paramType = "query"),
            @ApiImplicitParam(name = "startTime", value = "开始时间",required = false, paramType = "query"),
            @ApiImplicitParam(name = "endTime", value = "结束时间",required = false, paramType = "query"),
            @ApiImplicitParam(name = "monthTime", value = "月份 yyyyy-MM",required = false, paramType = "query"),
            @ApiImplicitParam(name = "sortField", value = "排序字段",required = false, paramType = "query"),
            @ApiImplicitParam(name = "sortType", value = "排序类型  asc正序  desc倒序",required = false, paramType = "query")
    })
    @GetMapping("/customer/refund/report")
    public Result<IPage<CustomerRefundReportVo>> customerRefundReport(Integer roleType, Long agentId,Long agentPid,Integer pRole, String userName, Long actId, Integer orderType, String startTime, String endTime,String monthTime, String sortField, String sortType){
        IPage<CustomerRefundReportVo> page = reportCustomerService.customerRefundReport(roleType, agentId,agentPid,pRole, userName, actId, orderType,  startTime, endTime,monthTime, sortField, sortType, initMpPage());
        return ResultUtil.success(page);
    }
    @ApiOperation(value = "9客服部报表--退货报表-导出excel")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "roleType", value = "角色类型",required = false, paramType = "query"),
            @ApiImplicitParam(name = "agentId", value = "代理商Id",required = false, paramType = "query"),
            @ApiImplicitParam(name = "agentPid", value = "代理商父Id",required = false, paramType = "query"),
            @ApiImplicitParam(name = "pRole", value = "代理商父角色",required = false, paramType = "query"),
            @ApiImplicitParam(name = "userName", value = "用户名",required = false, paramType = "query"),
            @ApiImplicitParam(name = "actId", value = "活动Id",required = false, paramType = "query"),
            @ApiImplicitParam(name = "orderType", value = "订单类型 1正价订单；2代理商活动订单；3秒杀活动订单",required = false, paramType = "query"),
            @ApiImplicitParam(name = "startTime", value = "开始时间",required = false, paramType = "query"),
            @ApiImplicitParam(name = "endTime", value = "结束时间",required = false, paramType = "query"),
            @ApiImplicitParam(name = "monthTime", value = "月份 yyyyy-MM",required = false, paramType = "query"),
            @ApiImplicitParam(name = "sortField", value = "排序字段",required = false, paramType = "query"),
            @ApiImplicitParam(name = "sortType", value = "排序类型  asc正序  desc倒序",required = false, paramType = "query")
    })
    @GetMapping("/customer/refund/report/excel")
    @NoNeedAccess
    public void customerRefundReportExcel(Integer roleType, Long agentId, Long agentPid,Integer pRole,String userName, Long actId, Integer orderType, String startTime, String endTime,String monthTime, String sortField, String sortType,HttpServletResponse response){
        IPage<CustomerRefundReportVo> page = reportCustomerService.customerRefundReport(roleType, agentId,agentPid,pRole, userName, actId, orderType,  startTime, endTime, monthTime, sortField, sortType, new Page(1,-1));
        try {
            EasyExcelUtil.writeExcel(response,CustomerRefundReportVo.class,page.getRecords(),"退货报表");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    @ApiOperation(value = "10客服部报表--会员销售报表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "roleType", value = "角色类型",required = false, paramType = "query"),
            @ApiImplicitParam(name = "agentId", value = "代理商Id",required = false, paramType = "query"),
            @ApiImplicitParam(name = "buyer", value = "用户名",required = false, paramType = "query"),
            @ApiImplicitParam(name = "role", value = "角色 1客服下单，2代理商下单，3客户下单",required = false, paramType = "query"),
            @ApiImplicitParam(name = "orderType", value = "订单类型 1正价订单；2代理商活动订单；3秒杀活动订单",required = false, paramType = "query"),
            @ApiImplicitParam(name = "startTime", value = "开始时间",required = false, paramType = "query"),
            @ApiImplicitParam(name = "endTime", value = "结束时间",required = false, paramType = "query"),
            @ApiImplicitParam(name = "sortField", value = "排序字段",required = false, paramType = "query"),
            @ApiImplicitParam(name = "sortType", value = "排序类型  asc正序  desc倒序",required = false, paramType = "query")
    })
    @GetMapping("/customer/buyer/report")
    public Result<IPage<CustomerBuyerReportVo>> customerBuyerReport(Integer roleType, Long agentId, String buyer, Integer orderType, Integer role, String startTime, String endTime, String sortField, String sortType){
        IPage<CustomerBuyerReportVo> page = reportCustomerService.customerBuyerReport(roleType, agentId, buyer, orderType, role, startTime, endTime, sortField, sortType, initMpPage());
        return ResultUtil.success(page);
    }
    @ApiOperation(value = "10客服部报表--会员销售报表-导出excel")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "roleType", value = "角色类型",required = false, paramType = "query"),
            @ApiImplicitParam(name = "agentId", value = "代理商Id",required = false, paramType = "query"),
            @ApiImplicitParam(name = "buyer", value = "用户名",required = false, paramType = "query"),
            @ApiImplicitParam(name = "role", value = "角色 1客服下单，2代理商下单，3客户下单",required = false, paramType = "query"),
            @ApiImplicitParam(name = "orderType", value = "订单类型 1正价订单；2代理商活动订单；3秒杀活动订单",required = false, paramType = "query"),
            @ApiImplicitParam(name = "startTime", value = "开始时间",required = false, paramType = "query"),
            @ApiImplicitParam(name = "endTime", value = "结束时间",required = false, paramType = "query"),
            @ApiImplicitParam(name = "sortField", value = "排序字段",required = false, paramType = "query"),
            @ApiImplicitParam(name = "sortType", value = "排序类型  asc正序  desc倒序",required = false, paramType = "query")
    })
    @GetMapping("/customer/buyer/report/excel")
    @NoNeedAccess
    public void customerBuyerReportExcel(Integer roleType, Long agentId, String buyer, Integer orderType, Integer role, String startTime, String endTime, String sortField, String sortType,HttpServletResponse response){
        IPage<CustomerBuyerReportVo> page = reportCustomerService.customerBuyerReport(roleType, agentId, buyer, orderType, role, startTime, endTime, sortField, sortType, new Page(1,-1));
        try {
            EasyExcelUtil.writeExcel(response,CustomerBuyerReportVo.class,page.getRecords(),"会员销售报表");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    @ApiOperation(value = "11客服部报表--秒杀活动返还款报表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "level", value = "等级",required = false, paramType = "query"),
            @ApiImplicitParam(name = "roleType", value = "角色类型",required = false, paramType = "query"),
            @ApiImplicitParam(name = "agentId", value = "代理商Id",required = false, paramType = "query"),
            @ApiImplicitParam(name = "userName", value = "客服/代理名称",required = false, paramType = "query"),
            @ApiImplicitParam(name = "startTime", value = "开始时间",required = false, paramType = "query"),
            @ApiImplicitParam(name = "endTime", value = "结束时间",required = false, paramType = "query"),
            @ApiImplicitParam(name = "sortField", value = "排序字段",required = false, paramType = "query"),
            @ApiImplicitParam(name = "sortType", value = "排序类型  asc正序  desc倒序",required = false, paramType = "query")
    })
    @GetMapping("/customer/seckill/rebate")
    public Result<IPage<CustomerSeckillRebateVo>> customerSeckillRebate(Integer roleType, Long agentId, String userName, String startTime, String endTime, String sortField, String sortType){
        IPage<CustomerSeckillRebateVo> page = reportCustomerService.customerSeckillRebate(roleType, agentId, userName, startTime, endTime, sortField, sortType, initMpPage());
        return ResultUtil.success(page);
    }
    @ApiOperation(value = "11客服部报表--秒杀活动返还款报表-导出excel")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "level", value = "等级",required = false, paramType = "query"),
            @ApiImplicitParam(name = "roleType", value = "角色类型",required = false, paramType = "query"),
            @ApiImplicitParam(name = "agentId", value = "代理商Id",required = false, paramType = "query"),
            @ApiImplicitParam(name = "userName", value = "客服/代理名称",required = false, paramType = "query"),
            @ApiImplicitParam(name = "startTime", value = "开始时间",required = false, paramType = "query"),
            @ApiImplicitParam(name = "endTime", value = "结束时间",required = false, paramType = "query"),
            @ApiImplicitParam(name = "sortField", value = "排序字段",required = false, paramType = "query"),
            @ApiImplicitParam(name = "sortType", value = "排序类型  asc正序  desc倒序",required = false, paramType = "query")
    })
    @GetMapping("/customer/seckill/rebate/excel")
    @NoNeedAccess
    public void customerSeckillRebateExcel(Integer roleType, Long agentId, String userName, String startTime, String endTime, String sortField, String sortType,HttpServletResponse response){
        IPage<CustomerSeckillRebateVo> page = reportCustomerService.customerSeckillRebate(roleType, agentId, userName, startTime, endTime, sortField, sortType, new Page(1,-1));
        try {
            EasyExcelUtil.writeExcel(response,CustomerSeckillRebateVo.class,page.getRecords(),"秒杀活动返还款报表");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    @ApiOperation(value = "11客服部报表--秒杀活动返还款报表--查看返还款20%分配")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "roleType", value = "角色类型",required = true, paramType = "query"),
            @ApiImplicitParam(name = "agentId", value = "代理商Id",required = true, paramType = "query"),
            @ApiImplicitParam(name = "userName", value = "客服/代理名称",required = false, paramType = "query"),
            @ApiImplicitParam(name = "startTime", value = "开始时间",required = false, paramType = "query"),
            @ApiImplicitParam(name = "endTime", value = "结束时间",required = false, paramType = "query"),
            @ApiImplicitParam(name = "sortField", value = "排序字段",required = false, paramType = "query"),
            @ApiImplicitParam(name = "sortType", value = "排序类型  asc正序  desc倒序",required = false, paramType = "query")
    })
    @GetMapping("/customer/seckill/rebate/all")
    public Result<IPage<CustomerSeckillRebateAllVo>> customerSeckillRebateAll(Integer roleType, Long agentId, String userName, String startTime, String endTime, String sortField, String sortType){
        IPage<CustomerSeckillRebateAllVo> page = reportCustomerService.customerSeckillRebateAll(roleType, agentId, userName, startTime, endTime, sortField, sortType, initMpPage());
        return ResultUtil.success(page);
    }
    @ApiOperation(value = "11客服部报表--秒杀活动返还款报表--查看返还款20%分配-导出excel")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "roleType", value = "角色类型",required = true, paramType = "query"),
            @ApiImplicitParam(name = "agentId", value = "代理商Id",required = true, paramType = "query"),
            @ApiImplicitParam(name = "userName", value = "客服/代理名称",required = false, paramType = "query"),
            @ApiImplicitParam(name = "startTime", value = "开始时间",required = false, paramType = "query"),
            @ApiImplicitParam(name = "endTime", value = "结束时间",required = false, paramType = "query"),
            @ApiImplicitParam(name = "sortField", value = "排序字段",required = false, paramType = "query"),
            @ApiImplicitParam(name = "sortType", value = "排序类型  asc正序  desc倒序",required = false, paramType = "query")
    })
    @GetMapping("/customer/seckill/rebate/all/excel")
    @NoNeedAccess
    public void customerSeckillRebateAllExcel(Integer roleType, Long agentId, String userName, String startTime, String endTime, String sortField, String sortType,HttpServletResponse response){
        IPage<CustomerSeckillRebateAllVo> page = reportCustomerService.customerSeckillRebateAll(roleType, agentId, userName, startTime, endTime, sortField, sortType, new Page(1,-1));
        try {
            EasyExcelUtil.writeExcel(response, CustomerSeckillRebateAllVo.class,page.getRecords(),"查看返还款20%分配");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    @ApiOperation(value = "11客服部报表--秒杀活动返还款报表--返还款20%订单详情")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "type", value = "类型  1个人返还款  2团队返还款",required = true, paramType = "query"),
            @ApiImplicitParam(name = "agentId", value = "代理商Id",required = true, paramType = "query"),
            @ApiImplicitParam(name = "startTime", value = "开始时间",required = false, paramType = "query"),
            @ApiImplicitParam(name = "endTime", value = "结束时间",required = false, paramType = "query"),
            @ApiImplicitParam(name = "sortField", value = "排序字段",required = false, paramType = "query"),
            @ApiImplicitParam(name = "sortType", value = "排序类型  asc正序  desc倒序",required = false, paramType = "query")
    })
    @GetMapping("/customer/seckill/rebate/detail")
    public Result<IPage<CustomerSeckillRebateDetailVo>> customerSeckillRebateDetail(Integer type,Long agentId,String startTime,String endTime,String sortField,String sortType){
        IPage<CustomerSeckillRebateDetailVo> page = reportCustomerService.customerSeckillRebateDetail(type, agentId, startTime, endTime, sortField, sortType, initMpPage());
        return ResultUtil.success(page);
    }
    @ApiOperation(value = "11客服部报表--秒杀活动返还款报表--返还款20%订单明细-导出excel")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "type", value = "类型  1个人返还款  2团队返还款",required = true, paramType = "query"),
            @ApiImplicitParam(name = "agentId", value = "代理商Id",required = true, paramType = "query"),
            @ApiImplicitParam(name = "startTime", value = "开始时间",required = false, paramType = "query"),
            @ApiImplicitParam(name = "endTime", value = "结束时间",required = false, paramType = "query"),
            @ApiImplicitParam(name = "sortField", value = "排序字段",required = false, paramType = "query"),
            @ApiImplicitParam(name = "sortType", value = "排序类型  asc正序  desc倒序",required = false, paramType = "query")
    })
    @GetMapping("/customer/seckill/rebate/detail/excel")
    @NoNeedAccess
    public void customerSeckillRebateDetailExcel(Integer type,Long agentId,String startTime,String endTime,String sortField,String sortType,HttpServletResponse response){
        IPage<CustomerSeckillRebateDetailVo> page = reportCustomerService.customerSeckillRebateDetail(type, agentId, startTime, endTime, sortField, sortType, new Page(1,-1));
        try {
            EasyExcelUtil.writeExcel(response, CustomerSeckillRebateDetailVo.class,page.getRecords(),"返还款20%订单明细");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }


    @ApiOperation(value = "11客服部报表--秒杀活动返还款报表--查看2%分红（一级分红）")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "agentId", value = "代理商Id",required = true, paramType = "query"),
            @ApiImplicitParam(name = "userName", value = "经销商关系名称（下单人）",required = false, paramType = "query"),
            @ApiImplicitParam(name = "startTime", value = "开始时间",required = false, paramType = "query"),
            @ApiImplicitParam(name = "endTime", value = "结束时间",required = false, paramType = "query"),
            @ApiImplicitParam(name = "sortField", value = "排序字段",required = false, paramType = "query"),
            @ApiImplicitParam(name = "sortType", value = "排序类型  asc正序  desc倒序",required = false, paramType = "query")
    })
    @GetMapping("/customer/seckill/bonus/one")
    public Result<IPage<CustomerSeckillBonusOneVo>> customerSeckillBonusOne(Long agentId,String userName,String startTime,String endTime, String sortField, String sortType){
        IPage<CustomerSeckillBonusOneVo> page = reportCustomerService.customerSeckillBonusOne(agentId, userName, startTime, endTime, sortField, sortType, initMpPage());
        return ResultUtil.success(page);
    }
    @ApiOperation(value = "11客服部报表--秒杀活动返还款报表--查看2%分红（一级分红）-导出excel")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "agentId", value = "代理商Id",required = true, paramType = "query"),
            @ApiImplicitParam(name = "userName", value = "经销商关系名称（下单人）",required = false, paramType = "query"),
            @ApiImplicitParam(name = "startTime", value = "开始时间",required = false, paramType = "query"),
            @ApiImplicitParam(name = "endTime", value = "结束时间",required = false, paramType = "query"),
            @ApiImplicitParam(name = "sortField", value = "排序字段",required = false, paramType = "query"),
            @ApiImplicitParam(name = "sortType", value = "排序类型  asc正序  desc倒序",required = false, paramType = "query")
    })
    @GetMapping("/customer/seckill/bonus/one/excel")
    @NoNeedAccess
    public void customerSeckillBonusOneExcel(Long agentId,String userName,String startTime,String endTime, String sortField, String sortType,HttpServletResponse response){
        IPage<CustomerSeckillBonusOneVo> page = reportCustomerService.customerSeckillBonusOne(agentId, userName, startTime, endTime, sortField, sortType, new Page(1,-1));
        try {
            EasyExcelUtil.writeExcel(response, CustomerSeckillBonusOneVo.class,page.getRecords(),"查看一级分红");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    @ApiOperation(value = "11客服部报表--秒杀活动返还款报表--查看1%分红（二级分红）")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "agentId", value = "代理商Id",required = true, paramType = "query"),
            @ApiImplicitParam(name = "userName1", value = "经销商关系名称(一级分红人)",required = false, paramType = "query"),
            @ApiImplicitParam(name = "userName", value = "经销商关系名称（下单人）",required = false, paramType = "query"),
            @ApiImplicitParam(name = "startTime", value = "开始时间",required = false, paramType = "query"),
            @ApiImplicitParam(name = "endTime", value = "结束时间",required = false, paramType = "query"),
            @ApiImplicitParam(name = "sortField", value = "排序字段",required = false, paramType = "query"),
            @ApiImplicitParam(name = "sortType", value = "排序类型  asc正序  desc倒序",required = false, paramType = "query")
    })
    @GetMapping("/customer/seckill/bonus/two")
    public Result<IPage<CustomerSeckillBonusTwoVo>> customerSeckillBonusTwo(Long agentId,String userName1,String userName,String startTime,String endTime, String sortField, String sortType){
        IPage<CustomerSeckillBonusTwoVo> page = reportCustomerService.customerSeckillBonusTwo(agentId, userName1, userName, startTime, endTime, sortField, sortType, initMpPage());
        return ResultUtil.success(page);
    }
    @ApiOperation(value = "11客服部报表--秒杀活动返还款报表--查看1%分红（二级分红）-导出excel")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "agentId", value = "代理商Id",required = true, paramType = "query"),
            @ApiImplicitParam(name = "userName1", value = "经销商关系名称(一级分红人)",required = false, paramType = "query"),
            @ApiImplicitParam(name = "userName", value = "经销商关系名称（下单人）",required = false, paramType = "query"),
            @ApiImplicitParam(name = "startTime", value = "开始时间",required = false, paramType = "query"),
            @ApiImplicitParam(name = "endTime", value = "结束时间",required = false, paramType = "query"),
            @ApiImplicitParam(name = "sortField", value = "排序字段",required = false, paramType = "query"),
            @ApiImplicitParam(name = "sortType", value = "排序类型  asc正序  desc倒序",required = false, paramType = "query")
    })
    @GetMapping("/customer/seckill/bonus/two/excel")
    @NoNeedAccess
    public void customerSeckillBonusTwoExcel(Long agentId,String userName1,String userName,String startTime,String endTime, String sortField, String sortType,HttpServletResponse response){
        IPage<CustomerSeckillBonusTwoVo> page = reportCustomerService.customerSeckillBonusTwo(agentId, userName1, userName, startTime, endTime, sortField, sortType, new Page(1,-1));
        try {
            EasyExcelUtil.writeExcel(response, CustomerSeckillBonusTwoVo.class,page.getRecords(),"查看二级分红");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    @ApiOperation(value = "11客服部报表--秒杀活动返还款报表--分红订单明细")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "type", value = "类型  1一级分红（2%）  2二级分红（1%）",required = true, paramType = "query"),
            @ApiImplicitParam(name = "agentId", value = "代理商Id",required = true, paramType = "query"),
            @ApiImplicitParam(name = "startTime", value = "开始时间",required = false, paramType = "query"),
            @ApiImplicitParam(name = "endTime", value = "结束时间",required = false, paramType = "query"),
            @ApiImplicitParam(name = "sortField", value = "排序字段",required = false, paramType = "query"),
            @ApiImplicitParam(name = "sortType", value = "排序类型  asc正序  desc倒序",required = false, paramType = "query")
    })
    @GetMapping("/customer/seckill/bonus/detail")
    public Result<IPage<CustomerSeckillBonusDetailVo>> customerSeckillBonusDetail(Integer type,Long agentId,String startTime,String endTime,String sortField,String sortType){
        IPage<CustomerSeckillBonusDetailVo> page = reportCustomerService.customerSeckillBonusDetail(type, agentId, startTime, endTime, sortField, sortType, initMpPage());
        return ResultUtil.success(page);
    }
    @ApiOperation(value = "11客服部报表--秒杀活动返还款报表--分红订单明细-导出excel")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "type", value = "类型  1一级分红（2%）  2二级分红（1%）",required = true, paramType = "query"),
            @ApiImplicitParam(name = "agentId", value = "代理商Id",required = true, paramType = "query"),
            @ApiImplicitParam(name = "startTime", value = "开始时间",required = false, paramType = "query"),
            @ApiImplicitParam(name = "endTime", value = "结束时间",required = false, paramType = "query"),
            @ApiImplicitParam(name = "sortField", value = "排序字段",required = false, paramType = "query"),
            @ApiImplicitParam(name = "sortType", value = "排序类型  asc正序  desc倒序",required = false, paramType = "query")
    })
    @GetMapping("/customer/seckill/bonus/detail/excel")
    @NoNeedAccess
    public void customerSeckillBonusDetailExcel(Integer type,Long agentId,String startTime,String endTime,String sortField,String sortType,HttpServletResponse response){
        IPage<CustomerSeckillBonusDetailVo> page = reportCustomerService.customerSeckillBonusDetail(type, agentId, startTime, endTime, sortField, sortType, new Page(1,-1));
        try {
            EasyExcelUtil.writeExcel(response, CustomerSeckillBonusDetailVo.class,page.getRecords(),"分红订单明细");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    @ApiOperation(value = "12客服部报表--代理商销售排行榜")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "isTeam", value = "团队或者个人  1个人 2团队 传空时全部",required = false, paramType = "query"),
            @ApiImplicitParam(name = "actId", value = "活动Id",required = false, paramType = "query"),
            @ApiImplicitParam(name = "orderType", value = "订单类型 1正价订单；2代理商活动订单；3秒杀活动订单",required = false, paramType = "query"),
            @ApiImplicitParam(name = "startTime", value = "开始时间",required = false, paramType = "query"),
            @ApiImplicitParam(name = "endTime", value = "结束时间",required = false, paramType = "query"),
            @ApiImplicitParam(name = "sortField", value = "排序字段",required = false, paramType = "query"),
            @ApiImplicitParam(name = "sortType", value = "排序类型  asc正序  desc倒序",required = false, paramType = "query"),
            @ApiImplicitParam(name = "agentName", value = "代理名称",required = false, paramType = "query")
    })
    @GetMapping("/customer/report/agent/ranking")
    public Result<IPage<CustomerReportAgentRankingVo>> customerReportAgentRanking(Integer orderType, Long actId, Integer isTeam, String startTime, String endTime, String sortField, String sortType,String agentName){
        IPage<CustomerReportAgentRankingVo> page = reportCustomerService.customerReportAgentRanking(orderType, actId, isTeam, startTime, endTime, sortField, sortType,agentName, initMpPage());
        return ResultUtil.success(page);
    }
    @ApiOperation(value = "12客服部报表--代理商销售排行榜-导出excel")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "isTeam", value = "团队或者个人  1个人 2团队 传空时全部",required = false, paramType = "query"),
            @ApiImplicitParam(name = "actId", value = "活动Id",required = false, paramType = "query"),
            @ApiImplicitParam(name = "orderType", value = "订单类型 1正价订单；2代理商活动订单；3秒杀活动订单",required = false, paramType = "query"),
            @ApiImplicitParam(name = "startTime", value = "开始时间",required = false, paramType = "query"),
            @ApiImplicitParam(name = "endTime", value = "结束时间",required = false, paramType = "query"),
            @ApiImplicitParam(name = "sortField", value = "排序字段",required = false, paramType = "query"),
            @ApiImplicitParam(name = "sortType", value = "排序类型  asc正序  desc倒序",required = false, paramType = "query"),
            @ApiImplicitParam(name = "agentName", value = "代理名称",required = false, paramType = "query")
    })
    @GetMapping("/customer/report/agent/ranking/excel")
    @NoNeedAccess
    public void customerReportAgentRankingExcel(Integer orderType, Long actId, Integer isTeam, String startTime, String endTime, String sortField, String sortType,String agentName,HttpServletResponse response){
        IPage<CustomerReportAgentRankingVo> page = reportCustomerService.customerReportAgentRanking(orderType, actId, isTeam, startTime, endTime, sortField, sortType,agentName, new Page(1,-1));
        try {
            EasyExcelUtil.writeExcel(response, CustomerReportAgentRankingVo.class,page.getRecords(),"代理商销售排行榜");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

